package com.ruoyi.web.controller.applet;

import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.system.domain.dto.BdmBalanceChangeDto;
import com.ruoyi.system.domain.dto.MineOrderDto;
import com.ruoyi.system.domain.vo.applet.AppletUserBalanceVo;
import com.ruoyi.system.service.IBdmExpensesDetailService;
import com.ruoyi.system.service.IBdmOrderService;
import com.ruoyi.system.service.IBdmRoyaltyRecordService;
import com.ruoyi.system.service.IIntegralService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 小程序我的Controller
 * 
 * @author ruoyi
 * @date 2024-12-14
 */
@RestController
@RequestMapping("/applet/mine")
public class AppletMineController extends BaseController
{
    @Autowired
    private IBdmRoyaltyRecordService bdmRoyaltyRecordService;

    @Autowired
    private IBdmExpensesDetailService bdmExpensesDetailService;

    @Autowired
    private IBdmOrderService bdmOrderService;

    @Autowired
    private IIntegralService integralService;

    /**
     * 小程序我的余额顶部统计
     * @return
     */
    @GetMapping("/topStatistics")
    public AjaxResult topStatistic() {
        return success(bdmRoyaltyRecordService.getMineBalance());
    }

    /**
     * 我的积分列表
     * @return
     */
    @GetMapping("/integralList")
    public AjaxResult integralList() {
        return success(integralService.selectIntegralList());
    }

    /**
     * 小程序我的收入明细列表
     */
    @GetMapping("/appletIncomeList")
    public AjaxResult incomeList(BdmBalanceChangeDto balanceChangeDto)
    {
        balanceChangeDto.setBusinessType("1");
        List<AppletUserBalanceVo> list = bdmRoyaltyRecordService.selectUserIncomeList(balanceChangeDto);
        return success(list);
    }

    /**
     * 小程序我的支出明细列表
     * @param
     * @return
     */
    @GetMapping("/appletExpensesList")
    public AjaxResult expensesList(BdmBalanceChangeDto balanceChangeDto)
    {
        balanceChangeDto.setBusinessType("2");
        List<AppletUserBalanceVo> list = bdmRoyaltyRecordService.selectUserIncomeList(balanceChangeDto);
        return success(list);
//        List<AppletUserExpensesVo> list = bdmExpensesDetailService.selectUserExpensesDetailList(bdmExpensesDetail);
//        return success(list);
    }

    /**
     * 我的订单
     * @return
     */
    @GetMapping("/orderList")
    public AjaxResult orderList(MineOrderDto mineOrderDto) {
        return success(bdmOrderService.selectAppletOrderList(mineOrderDto));
    }

}
